package panel.help
{
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.text.TextField;
	
	import assists.HtmlText;
	import assists.TextFieldUtils;
	
	public class TrafficItem extends Sprite
	{
		private var _stage:Stage;
		private var _startTxt:TextField = new TextField();
		private var _endTxt:TextField = new TextField();
		private var _timeTxt:TextField = new TextField();
		public var fontSize:int = 18;
		public function TrafficItem(stage:Stage)
		{
			_stage = stage;
			
			_startTxt.autoSize = "left";
			_startTxt.mouseEnabled = false;
			
			_endTxt.autoSize = "left";
			_endTxt.mouseEnabled = false;
			
			_timeTxt.autoSize = "left";
			_timeTxt.mouseEnabled = false;
		}
		
		public function show(data:Object):void
		{
		     TextFieldUtils.setHtmlText(_startTxt,HtmlText.format(data.start,0xffffff,fontSize));
			 TextFieldUtils.setHtmlText(_endTxt,HtmlText.format(data.end,0xffffff,fontSize));
			 TextFieldUtils.setHtmlText(_timeTxt,HtmlText.format(data.time,0xffffff,fontSize));
			 
		     layout();	 
		}
		
		private function layout():void
		{
			var dis:int = _stage.stageWidth / 3;
			_startTxt.x = (dis - _startTxt.width) * 0.5;
			_endTxt.x = (dis - _endTxt.width) * 0.5 + dis;
			_timeTxt.x = (dis - _timeTxt.width) * 0.5 + 2 * dis;
			this.addChild(_startTxt);
			this.addChild(_endTxt);
			this.addChild(_timeTxt);
		}
		
	}
}